package com.mathdroid.model.abilities.specs.sniper;

import com.mathdroid.model.abilities.Ability;
import com.mathdroid.model.enums.EDmgType;

public final class Cull extends Ability {
	
	/**
	 * Generated UID.
	 */
	private static final long serialVersionUID = -6838161576651226010L;
	
	/**
	 * The amount of poison effects on the target.
	 * The default is "1" for ToolTip purposes.
	 */
	private int poisonEffects = 1;
	
	/*
	 * Cull has two effects that have to be treated individual.
	 * The first effect is the weapon damage DoT.
	 */
	private double eff1StandardHealthPercentMax = 0.078;
	private double eff1StandardHealthPercentMin = 0.078;
	private double eff1AmountModifierPercent = -0.48;
	private double eff1Coefficient = 0.78;
	private double eff1Interval = 1000d;
	
	/*
	 * The second effect is the additional internal damage DoT.
	 */
	private double eff2StandardHealthPercentMax = 0.038;
	private double eff2StandardHealthPercentMin = 0.038;
	private double eff2Coefficient = 0.38;
	private double eff2Interval = 1000d;

	public Cull() {
		this.setRequiredTalent("Cull");
		this.setName("Cull");
		this.setIconName("cull");
		this.setResource("Energy");
		this.setCost(30d);
		this.setCooldownMs(9000d);
		this.setDirectDamageType(EDmgType.ENERGY);
		this.setPeriodicDamageType(EDmgType.INTERNAL);
		
		this.setTrainableLevel(30);
	}
	
	@Override
	public String getDescription() {
		return "Fires a volley of bolts at the target, dealing "
			+ this.getWeaponDamageDoTMin() + " - " 
			+ this.getWeaponDamageDoTMax() + " weapon damage each second. " 
			+ "For each of your poison effects present on the target, "
			+ "the target is culled for an additional " 
			+ this.getInternalDamageDoT() + " internal damage each second.";
	}
	
	public double getWeaponDamageDoTMin() {
		return
			(this.eff1AmountModifierPercent + 1d) 
			* this.getCharStats().getRangedDamagePrimaryMin()
		
			+ eff1Coefficient 
			* this.getCharStats().getTotalBonusDamageTechForce()
		
			+ eff1StandardHealthPercentMin 
			* this.getStdDmg();
	}
	
	public double getWeaponDamageDoTMax() {
		return
			(this.eff1AmountModifierPercent + 1d) 
			* this.getCharStats().getRangedDamagePrimaryMax()
		
			+ eff1Coefficient 
			* this.getCharStats().getTotalBonusDamageTechForce()
		
			+ eff1StandardHealthPercentMax 
			* this.getStdDmg();
	}
	
	public double getInternalDamageDoT() {
		/* There is no weapon damage involved, min and max are the same. 
		 * Note that this scales with the amount of poison effects. */
		return this.poisonEffects
			* (
				eff2Coefficient 
				* this.getCharStats().getTotalBonusDamageTechForce()
			
				+ eff2StandardHealthPercentMin 
				* this.getStdDmg()
			);
	}

	@Override
	public double getMinPeriodic() {
		return this.getWeaponDamageDoTMin() + this.getInternalDamageDoT();
	}

	@Override
	public double getMaxPeriodic() {
		return this.getWeaponDamageDoTMax() + this.getInternalDamageDoT();
	}

	@Override
	public double getMinDirect() {
		return 0d;
	}

	@Override
	public double getMaxDirect() {
		return 0d;
	}

	/**
	 * @param p the poisonEffects to set
	 */
	public void setPoisonEffects(final int p) {
		this.poisonEffects = p;
	}
}
